package com.example.demo.common;

import com.example.demo.entity.UserInfo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @author vivi
 * @description
 * @date 2024/6/2
 */
// 当前登录用户相关的操作
public class UserSessionUtils {
    // 得到当前登录用户
    public static UserInfo getSessionUser(HttpServletRequest request) {
        HttpSession session = request.getSession(false);
        if (session != null && session.getAttribute(AppVariable.USER_SESSION_KET) != null) {
            // 说明用户已正常登录
            return (UserInfo) session.getAttribute(AppVariable.USER_SESSION_KET);
        }
        return null;
    }
}





















